package cn.tedu.imop.basic.controller;

import cn.tedu.imop.api.model.RestResult;
import cn.tedu.imop.api.model.RestResultUtils;
import cn.tedu.imop.basic.entity.Member;
import cn.tedu.imop.basic.service.MemberService;
import cn.tedu.imop.common.constants.Constants;
import cn.tedu.imop.common.pojo.PageData;
import com.github.pagehelper.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "会员管理")
@RestController //==@Controller + @ResponseBody
@RequestMapping(Constants.CONTROLLER_API_VERSION+"/member")
public class MemberController {
    private final MemberService memberService;

    public MemberController(MemberService memberService) {
        this.memberService = memberService;
    }

    @ApiOperation("会员注册")
    @PostMapping
    public RestResult createMember(Member member) {
        memberService.createMember(member);
        return RestResultUtils.success();
    }
    @ApiOperation("会员列表")
    @GetMapping
    public RestResult<PageData<Member>> getMemberList(Member member) {
        return RestResultUtils.success(memberService.getMemberList(member));
    }
}
